<?php


include '../test_upload_pic.php';
session_start();
ob_start();
date_default_timezone_set('PRC');
//var_dump($_POST);exit;
$error='';
$title = $_POST['title'];
$type = $_POST['type'];
$content = $_POST['editor01'];


	//将内容插入到数据库中
	if(empty($error)){
		include '../config.php';
		$link=mysql_connect(HOST,DBUSER,DBPASS) or die('数据库连接失败');
		mysql_select_db(DBNAME,$link);
		mysql_set_charset('utf8');
		
		if(empty($error)){
			$sql= "INSERT INTO t_news (title,type,content,addtime)
			VALUES('".$title."','".$type."','".$content."','".date('Y-m-d')."')";
			$result=mysql_query($sql);
			$tid=mysql_insert_id();
			if($tid<=0){
				$error=$sql.$tid.'插入数据库失败!';
			}
		}
		mysql_close($link);
	}
	//错误跳转
	if(empty($error)){
		header('Location:newsList.php?tid='.$tid.'&title='.$title);
	}else{
		header('Location:newsAdd.php?error='.$error.'title='.$title.'begin='.$begin);
	}
	ob_end_flush();
	?>